package com.example.p221configurationproperties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
@EnableConfigurationProperties(AppProperties.class)
public class P221ConfigurationPropertiesApplication {

    private static final Logger log =
            LoggerFactory.getLogger(P221ConfigurationPropertiesApplication.class);


    public static void main(String[] args) {
        //SpringApplication.run(P221ConfigurationPropertiesApplication.class, args);
        ConfigurableApplicationContext applicationContext =
                SpringApplication.run(P221ConfigurationPropertiesApplication.class, args);
        AppService appService =
                applicationContext.getBean(AppService.class);
        log.info(appService.getAppProperties().toString());
    }
}
